package com.example.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

/**
 * Project:spring-boot-kafka
 * <p>
 * Title:KafkaMessageProducer.java
 * <p>
 * Description:
 * <p>
 * Copyrigth:Jiang Software LTD.co Copyright (c) 2021
 * <p>
 * 
 * @version 1.0
 * @since 1.8
 * @author jiang
 * @history 2021 jiang create
 */

@Service
public class MessageProducer {

	// kafka消息模板
	@Autowired
	private KafkaTemplate<String, String> kafkaTemplate;

	public void send(String text) {
		// 发送消息
		this.kafkaTemplate.sendDefault("messagekey", text);
	}

}